package com.tmall.wireless.virtualviewdemo.utils.imageloader.core.imageaware;

import com.tmall.wireless.virtualviewdemo.utils.imageloader.core.assist.ImageSize;
import com.tmall.wireless.virtualviewdemo.utils.imageloader.core.assist.ViewScaleType;
import ohos.agp.components.Component;
import ohos.agp.components.element.Element;
import ohos.agp.utils.TextTool;
import ohos.media.image.PixelMap;

public class NonViewAware implements ImageAware {

    protected final String imageUri;
    protected final ImageSize imageSize;
    protected final ViewScaleType scaleType;

    public NonViewAware(ImageSize imageSize, ViewScaleType scaleType) {
        this(null, imageSize, scaleType);
    }

    public NonViewAware(String imageUri, ImageSize imageSize, ViewScaleType scaleType) {
        if (imageSize == null) throw new IllegalArgumentException("imageSize must not be null");
        if (scaleType == null) throw new IllegalArgumentException("scaleType must not be null");

        this.imageUri = imageUri;
        this.imageSize = imageSize;
        this.scaleType = scaleType;
    }

    @Override
    public int getWidth() {
        return imageSize.getWidth();
    }

    @Override
    public int getHeight() {
        return imageSize.getHeight();
    }

    @Override
    public ViewScaleType getScaleType() {
        return scaleType;
    }

    @Override
    public Component getWrappedView() {
        return null;
    }

    @Override
    public boolean isCollected() {
        return false;
    }


    @Override
    public int getId() {
        return TextTool.isNullOrEmpty(imageUri) ? super.hashCode() : imageUri.hashCode();
    }

    @Override
    public boolean setImageElement(Element element) {
        return false;
    }

    @Override
    public boolean setImagePixelMap(PixelMap pixelMap) {
        return false;
    }


}